<template>
	<view class="rent-pages">
		<template v-if="list.length>0">
			<view class="info-item" v-for="item in list" :key="item.id"
				@click="navigate('/page_pack/my_pages/relet/record?id='+item.idValue)">
				<view class="rent-item">
					<view class="rent-info">
						<image :src="imgStorage+'/login/lianzu.png'" class="info-icon"
							v-if="item.houseType.includes('廉租')">
						</image>
						<image :src="imgStorage+'/login/gongzu.png'" class="info-icon"
							v-else-if="item.houseType.includes('公租')">
						</image>
						<image :src="imgStorage+'/login/zhiguan.png'" class="info-icon"
							v-else-if="item.houseType.includes('直管')">
						</image>
						<view class="title">
							{{item.areaName||''}}{{item.streetName||''}}{{item.buildingNumber||''}}#{{item.unitNumber||''}}-{{item.floorLevel||''}}0{{item.roomNumber||''}}
						</view>
					</view>
					<view class="small-btn normal" v-if="item.status==0"
						@click="navigate('/page_pack/renewal/renewal')">
						续租</view>
					<view class="text" v-if="item.status==1" style="color: #ffa100;">待审核</view>
					<view class="text" v-if="item.status==3" style="color: #18aa00;">续租成功</view>
				</view>
			</view>
		</template>
		<view v-if="more==false&&list.length==0" class="empty">暂无数据</view>
		<view v-else-if="more==false&&list.length>0" class="empty">没有更多了</view>
	</view>
</template>

<script>
	import {
		isMore
	} from '@/util/util.js'
	import {
		setStorage,
		getStorage
	} from '@/util/auth.js';
	import {
		getRecordListApi
	} from '@/api/renewal.js'
	export default {
		data() {
			return {
				selectInfo: {},
				more: true,
				conf: {
					page: 1,
					limit: 10,
				},
				list: []
			}
		},
		methods: {
			handleRefresh() {
				this.conf.page = 1;
				this.more = true
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.getList(true)
			},
			getList(refresh = false) {
				getRecordListApi({
					page: this.conf.page,
					limit: this.conf.limit
				}).then(res => {
					let list = res.items || [];
					if (refresh) {
						this.list = list;
					} else {
						this.list = [...this.list, ...list]
					}
					this.more = isMore(this.conf.page, this.conf.limit, res.total)
				})
			},
			onReachBottom() {
				if (this.more) {
					this.conf.page++;
					uni.showLoading({
						title: '加载中',
						mask: true
					})
					this.getList();
				}
			},
		},
		onLoad() {
			this.getList(true)
		},
		onShow() {
			this.selectInfo = getStorage('selectInfo')
		}
	}
</script>

<style lang="scss" scoped>
	.rent-pages {
		padding: 30rpx;

		.info-item {
			width: 100%;
			border-radius: 20rpx;
			background-color: #fff;
			padding: 50rpx 30rpx;
			margin-bottom: 30rpx;

			.rent-item {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.rent-info {
					width: calc(100% - 150rpx);
					display: flex;
					align-items: center;

					.info-icon {
						width: 40rpx;
						height: 40rpx;
						margin-right: 10rpx;
					}

					.title {
						width: calc(100% - 50rpx);
						font-size: 32rpx;
						font-weight: bold;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
				}

				.small-btn {
					width: 150rpx;
					height: 60rpx;
					font-size: 28rpx;
				}

				.text {
					font-size: 30rpx;
				}
			}
		}
	}
</style>